import { Paths } from "@/paths";
import { useMemo } from "react";
import { IUseNavItemsOpts, NavItem } from "./useNavItems";
import { NavMenu } from "./useNavMenu";

const root: [Paths.All, NavItem<Paths.All>[]] = [
  Paths.All.Root, [
    Paths.All.LocalWXSessions,
    Paths.All.LocalWXContacts,
    Paths.All.DevTasks,
    [Paths.All.Management, [
      Paths.All.WXAccountManagement,
      Paths.All.WXContactsManagement,
      Paths.All.WXSessionsManagement,
      Paths.All.WXMessagesManagement
    ]],
    Paths.All.About,
  ]
]
export interface INavConf extends IUseNavItemsOpts<Paths.All>, NavMenu.IUseOpts<Paths.All> { }

export function useNavConf(): INavConf {
  const icons = Paths.useIcons();
  const names = Paths.useNames();
  const navigate = Paths.useNavigate();
  const has_permission = Paths.usePermission();
  
  return useMemo(() => {
    const ret: INavConf = {
      is_page: p => false,
      get_icon: p => icons[p],
      get_name: p => names[p],
      has_permission,
      root,
      navigate,
      defaultValue: [Paths.All.About]
    }
    return ret;
  }, [has_permission, names, icons]);
}